<?php
namespace App\Service\Admin\Qudao;

use Illuminate\Support\Facades\DB;

class CommonService extends BaseService
{
    //首页

    /**
     * 列表
     * @return array
     */
    public function getList()
    {
        $res = $this->dbwbConn($this->dbQdConfig)
            ->whereNotIn('id', [1, 2, 8, 11])
            ->get();
        if (!count($res)) {
            return $this->toback(-2, '没有记录');
        }
        $arys = [];
        foreach ($res as $v) {
            $v = (array) $v;
            $arys[] = [
                'id' => $v['id'],
                'title' => $v['des'],
                //'key' => $v['key'],
                'val' => $v['value'],
            ];
        }
        return $this->toback(0, '', $arys);
    }

    /**
     * 修改
     * @return array
     */
    public function modify($id, $val)
    {
        $res = (array) $this->dbwbConn($this->dbQdConfig)->where('id', $id)->first();
        if (empty($res)) {
            return $this->toback(-2, '没有记录');
        }
        $this->dbwbConn($this->dbQdConfig)->where('id', $id)->update(['value' => $val]);

        return $this->toback();
    }
}